import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/Home.vue'
import Login from '@/views/Login.vue'
import Register from '@/views/Register.vue'

// 定义路由
const routes = [
  {
    path: '/',
    name: 'Home',
      redirect: '/shouye',
    component: Home,
      children: [
        {
          path: '/shouye',
          name: 'Shouye',
          component: () => import('@/views/shouye.vue'),
            meta: {
              title: '首页',
                activeMenu: '/shouye'
            }
        },
          {
            path: '/songs',
            name: 'SongList',
            component: () => import('@/views/SongList.vue'),
            meta: {
              title: '歌曲列表',
                activeMenu: '/songs'
            }
          },
          {
            path: '/singers',
            name: 'SingerList',
            component: () => import('@/views/SingerList.vue'),
            meta: {
              title: '歌手列表',
                activeMenu: '/singers'
            }
          },
          {
              path: '/singers/:id',
              name: 'SingerDetail',
              component: () => import('@/views/SingerDetail.vue'),
              meta: {
                  title: '歌手详情',
                  activeMenu: '/singers'
              }
          },
          {
              path: '/albums',
              name: 'AlbumList',
              component: () => import('@/views/AlbumList.vue'),
              meta: {
                  title: '专辑列表',
                  activeMenu: '/albums'
              }
          },
          {
              path: '/album/:id',
              name: 'AlbumDetail',
              component: () => import('@/views/AlbumDetail.vue'),
              meta: {
                  title: '专辑详情',
                  activeMenu: '/albums'
              }
          },
          {
              path: '/ranks',
              name: 'RankList',
              component: () => import('@/views/RankList.vue'),
              meta: {
                  title: '排行榜列表',
                  activeMenu: '/ranks'
              }
          },
          {
              path: '/rank/:id',
              name: 'RankDetail',
              component: () => import('@/views/RankDetail.vue'),
              meta: {
                  title: '排行榜详情',
                  activeMenu: '/ranks'
              }
          },
          {
              path: '/profile',
              name: 'Profile',
              component: () => import('@/views/Profile.vue'),
              meta: {
                  title: '个人中心',
                  activeMenu: '/profile'
              }
          },
          {
              path: '/search',
              name: 'Search',
              component: () => import('@/views/Search.vue'),
              meta: {
                  title: '搜索',
                  activeMenu: '/search'
              }
          },
          {
              path: '/song/:id',
              name: 'Song',
              component: () => import('@/../../music-manage/src/views/Song.vue'),
              meta: {
                  title: '歌曲详情',
                  activeMenu: '/songs'
              }
          }
      ]
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  }
]

// 创建路由器实例
const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
